<template>
	<view class="index_Content">

		<!-- 客服留言组件 -->
		<chatMessageModal :mobile="mobile" :chatMessageModalIsShow.sync="chatMessageModalIsShow" />

		<div class="logo">
			<image src="/static/newIndex/logo.png" mode="widthFix" style="width: 176rpx;"></image>
			<image src="/static/newIndex/logo-text.png" v-if="lang==='zh'" mode="widthFix"
				style="width: 237rpx;margin-left:16rpx"></image>
			<image src="/static/newIndex/logo-text-ru.png" v-if="lang==='ru'" mode="widthFix"
				style="width: 237rpx;margin-left:16rpx"></image>
		</div>

		<image v-if="lang=='zh'" class="images_header" src="/static/newIndex/header.png" mode="" />
		<image v-if="lang=='ru'" class="images_header" src="/static/newIndex/header_ru.png" mode="" />

		<div class="header-text">
			<image src="/static/newIndex/header-text-zh.png" v-if="lang==='zh'" mode="widthFix" style="width:240rpx">
			</image>
			<image src="/static/newIndex/header-text-ru.png" v-if="lang==='ru'" mode="widthFix" style="width:400rpx">
			</image>
		</div>

		<div class="goindex" @click="goTest">
			<image style="width: 60%;" :src="serverImageUrl('/static/images/airobot.png')" mode="widthFix"></image>
			<div style="margin-top: 8rpx;">
				{{$t('小助手')}}
			</div>
		</div>

		<!-- 通知 -->
		<Notification />
		<!-- 通知 -->
		<view class="Outer_container">

			<!-- 头部搜索 -->
			<view class="index_header">
				<view class="index_Search">
					<image :src="HTTP_IMG_UTL+'index_ser.png'" style="width: 28rpx;height: 28rpx;" mode="" />
					<!-- <view style="font-size: 24rpx;margin-left: 10rpx;">请输入您想要查找的内容</view> -->
					<input confirm-type="search" v-model="inputValue" @confirm="handeleSearch"
						style="font-size: 24rpx;width: 100%;margin-left: 15rpx;" type="text"
						:placeholder="$t('请输入您想要查找的内容')">
				</view>
			</view>
			<!-- 轮播图 -->


			<!-- 胶囊广告 -->
			<div class="chatMessageBtn" @click="customer">
				<!--<div class="chatMessageBtn" @click="chatMessageModalIsShow=true">-->

				<!-- 	<image v-if="lang=='zh'" :src="serverImageUrl('/t1.png')" mode="widthFix" class="title"
					style="width:220rpx">
				</image>
				<image v-else :src="serverImageUrl('/t2.png')" mode="widthFix" class="title title2"
					style="width:500rpx"></image>
				<image :src="serverImageUrl('/tbg.png')" mode="widthFix" style="width: 100%;"></image>
				 -->
				<image src="/static/newIndex/zh.png" v-if="lang=='zh'" style="width: 100%;" mode="widthFix"></image>
				<image src="/static/newIndex/ru.png" v-else style="width: 100%;" mode="widthFix"></image>
			</div>



			<BusinessTab :look_auth="look_auth" :lang="lang" :userInfoFull="userInfoFull"
				:jurisdictionList="jurisdictionList" />

			<!-- 消息轮播 -->
			<view
				style="margin-top: 20rpx;width: 100%;padding:0 30rpx;box-sizing: border-box;border-radius: 16rpx;overflow: hidden">
				<u-notice-bar style="border-radius: 16rpx;" mode="horizontal" :list="list" bg-color="#FFFFFF"
					type="none"></u-notice-bar>
			</view>



			<!-- 	<view class="index_Swiper">
				<u-swiper :list="swiperList" mode="none" border-radius="28"></u-swiper>
			</view> -->


			<!-- 	<div style="margin-top: 50rpx;">
				{{jurisdictionList.map(item=>item.title)}}
			</div> -->


			<!-- 功能模块-横向滑动 -->
			<view class="index_jurs" v-if="false">
				<scroll-view class="scroll-view" scroll-x="true">
					<view class="scroll-content">
						<view class="item" v-for="(item,index) in jurisdictionList" :key="index"
							@click="handeleRouter(item)">
							<image :src="lang==='zh'?IMGURL+item.image:IMGURL+item.image_ru"
								style="width: 80rpx;height: 80rpx;margin-bottom: 16rpx;" />

							<view :class="lang==='zh'?'container_zh':'container_ru'">
								<view>{{lang==='zh'?item.title:item.title_ru}}</view>
							</view>
						</view>
					</view>
				</scroll-view>
			</view>
		</view>

		<menu1 v-if="logOff" />
		<menu2 v-if="logOff" />

		<div style="text-align: center;margin-top: 24rpx;">
			<image src="/static/newIndex/recommend.png" mode="widthFix" v-if="lang=='zh'" style="width:244rpx"> </image>
			<image src="/static/newIndex/recommend_ru.png" mode="widthFix" v-if="lang=='ru'" style="width:578rpx">
			</image>
		</div>
		<!-- 猜你喜欢 -->
		<view class="commodityTJ" v-if="likeList.length>0">
			<view class="scroll-view_H_wc">
				<div v-for="(item,index) in likeList" :key="index"
					style="padding: 15rpx;box-sizing: border-box;width: 50%;">
					<view @click="handeleGoos(item)" class="goodsImage">
						<u-image style="border-radius: 30rpx;" width="100%" height="231rpx" :src="IMGURL+item.logo"
							border-radius="11">
							<u-loading slot="loading"></u-loading>
						</u-image>

						<view class="classLink_block">
							<view class="over-line">{{lang==='zh'?item.name:item.name_ru}}</view>
							<view class="flex">
								<image :src="HTTP_IMG_UTL+'refi_@4x.png'"
									style="width: 19rpx;height: 19rpx;flex-shrink:0" />
								<view
									style="font-size: 22rpx;color:#6d6d6d;margin-left: 8rpx;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;"
									class="flex">
									<text v-if="lang=='zh'"> {{item.departurecitys.mergename}}</text>
									<text v-if="lang=='ru'"> {{item.departurecitys.mergename_ru}}</text>
								</view>
							</view>

							<view class="flex" style="margin-top: 8rpx;">
								<image :src="HTTP_IMG_UTL+'Page_views@4x.png'"
									style="width: 16rpx;height: 16rpx;flex-shrink:0" />
								<view style="font-size: 22rpx;color:#6d6d6d;margin-left: 8rpx;">{{$t(item.view_count)}}
								</view>
							</view>

							<view class="over-line_salary">
								<view v-if="item.desire_price">
									<span v-if="lang=='zh'"
										style="font-size: 32rpx;color: #DE4023;font-weight: bold;">{{item.desire_price}}</span>
									<span v-if="lang=='zh'"
										style="font-size: 22rpx;color: #DE4023;margin-left: 3rpx;">{{$t(item.price_unit)}}</span>
									<span v-if="lang=='zh'"
										style="font-size: 22rpx;color: #DE4023;margin-left: 10rpx;">({{lang==='zh'?item.number_unit:item.number_unit_ru}})</span>

									<span v-if="lang=='ru'"
										style="font-size: 24rpx;color: #DE4023;font-weight: bold;">{{item.desire_price}}</span>
									<span v-if="lang=='ru'"
										style="font-size: 12rpx;color: #DE4023;margin-left: 3rpx;">{{$t(item.price_unit)}}</span>
									<span v-if="lang=='ru'"
										style="font-size: 12rpx;color: #DE4023;margin-left: 10rpx;">({{lang==='zh'?item.number_unit:item.number_unit_ru}})</span>
								</view>
							</view>
							<view class="btn-group">
								<view class="relativeAb">
									<view class="relativeAb_block" @click.stop="handelePoa(1,item)">
										{{$t(logOff?'招标比价':'货物求购')}}
									</view>
									<view class="relativeAb_block relativeAb_block2" @click.stop="handelePoa(2,item)">
										{{$t('即时沟通')}}
									</view>
								</view>
							</view>
						</view>
					</view>
				</div>
			</view>
		</view>


		<div style="height: 150rpx;"></div>

		<!-- 商品推荐 -->
		<view class="index_recommend" v-if="false">
			<!-- 商品推荐文字 -->
			<view class="recommendTJ">
				<view class="Vertical_line"></view>
				<view>{{$t('商品推荐')}}</view>
			</view>
			<!-- 商品列表 -->
			<view class="goods_container" v-if="goodsList.length>0">
				<view @click="handeleGoos(item)" v-for="(item,index) in goodsList" :key="index"
					:class="(index % 2 === 0)?'goods_block_d':'goods_block_s'">
					<u-image width="336rpx" height="320rpx" :src="IMGURL+item.logo" border-radius="16">
						<u-loading slot="loading"></u-loading>
					</u-image>
					<!-- 商品名称 -->
					<view class="goodsTitle">{{lang==='zh'?item.name:item.name_ru}}</view>
					<!-- 商品介绍 -->
					<view class="goodsBrief">{{lang==='zh'?item.goods_brief:item.goods_brief_ru}} </view>
					<view style="height: 48rpx;width: 100%;margin-top: 9rpx;position: relative;">
						<image :src="HTTP_IMG_UTL+'3211.png'" style="width: 100%;height: 48rpx;" mode="" />
						<view class="poa">
							<view class="pos_block" @click.stop="handelePoa(1,item)">{{$t(logOff?'招标比价':'货物求购')}}</view>
							<view class="pos_block" @click.stop="handelePoa(2,item)">{{$t('即时沟通')}}</view>
						</view>
					</view>
				</view>
			</view>
			<view
				style="margin-top: 100rpx;width: 100%;display: flex;align-items: center;justify-content: center;color: #999999;"
				v-else>{{$t('暂无信息')}}</view>
			<!-- 临时添加 -->
			<view style="height: 50rpx;"></view>
			<!-- 商品推荐有图无字   暂时隐藏-->
			<view class="images_list" v-if="false">
				<view v-for="(item,index) in imageList" :key="index"
					:class="(index % 2 === 0)?'images_block_s':'images_block_d'"></view>
			</view>
		</view>

		<!-- <div style="display: none;" @click.stop="goAi" class="goAi">
			<div>AI助手</div>
			<div>
				测试入口
			</div>
			<Service @click.stop="goAi" />
		</div> -->




		<!-- 认证 -->

		<u-popup v-model="isAuthentication" mode="center" :mask-close-able="ask" border-radius="16">
			<view class="index_isAuthentication">
				<view class="index_reminder">{{$t('温馨提示')}}</view>
				<scroll-view :scroll-top="scrollTop" scroll-y="true" style="height: 400rpx;width: 80%;">
					<text>{{$t('亲爱的用户： 为保证您的使用体验，获得更优质的服务质量，您需在平台内认证您的身份信息。 认证成功后，您将获得更为智能的助手服务，触发更精准的推送信息，以及专属图标展示！立即开始认证吧！')}}</text>
				</scroll-view>
				<u-button style="margin-top: 30rpx;font-size: 14px;" @click="handeleGoAuthentication"
					v-if="user_id>0">{{$t('立即认证')}}</u-button>
				<u-button style="margin-top: 30rpx;font-size: 14px;" @click="logOut" v-else>{{$t('请先登录')}}</u-button>
				<u-button style="margin-top: 30rpx;font-size: 14px;" @click="logOut">{{$t('退出登录')}}</u-button>
				<view style="width:100%;height:25px"></view>

			</view>
		</u-popup>


		<!-- <tabbar /> -->


		<!-- 中国用户发布弹窗 -->
		<u-mask :show="show" @click="close">
			<view class="warp">
				<view style="width: 500rpx;height: 50rpx;display: flex;justify-content: flex-end;">
					<image @click="close" style="width: 40rpx;height: 40rpx;position: relative;margin-right: -20rpx;"
						:src="HTTP_IMG_UTL+'clone.png'" mode=""></image>
				</view>
				<image @click="handeleActivities" class="warpImage" :src="HTTP_IMG_UTL+'haha_20240923195014.png'"
					mode=""></image>
			</view>
		</u-mask>


		<update v-if="updateIsShow" ref="updateRef" />

	</view>
</template>

<script>
	import tabbar from "@/components/tabbar/index.vue";
	import index from "@/pages/tabbar/index.vue";
	import BusinessTab from "@/pages/tabbar/components/businessTab.vue"
	import menu1 from "@/pages/tabbar/components/menu1.vue"
	import menu2 from "@/pages/tabbar/components/menu2.vue"
	import chatMessageModal from "@/pages/tabbar/components/chatMessageModal.vue"

	// #ifndef MP-WEIXIN
	import TencentCloudChat from '@tencentcloud/chat';
	// 引入setPermissions.js文件
	import {
		getPermissions
	} from '@/common/getPermissions.js';
	import {
		init,
		login
	} from '@/utils/im';
	import permision from "@/js_sdk/wa-permission/permission.js"
	// #endif

	import {
		HTTP_REQUEST_URL,
		IMAGE_URL,
		HTTP_IMG_UTL
	} from '@/config/app';
	import {
		isBase64,
		time,
		createC2CConversation,
		getCapsule,
		createVoiceCall
	} from "@/common/public";

	export default {
		components: {
			tabbar,
			BusinessTab,
			menu2,
			menu1,
			chatMessageModal
		},
		data() {
			return {
				userInfoFull: {},
				HTTP_IMG_UTL,
				closeable: true,
				show: false, //中国活动弹窗
				list: [], //广播消息
				scrollTop: 0,
				ask: false,
				inputValue: '', //搜索内容
				isShow: false,
				link: true,
				imageList: [1, 2, 3, 4], //商品推荐有图无字
				goodsList: [], //商品列表
				likeList: [], //猜你喜欢数组
				jurisdictionList: [], //功能模块数组
				swiperList: [], //轮播图
				lang: 'zh',
				IMGURL: IMAGE_URL, //图片前缀
				current: 0, //轮播图参数
				show_city: '不限',
				page: 1,
				iconUrl: { //路由地址
					// goods1: "/pages/index/goodsPromotion/goodsPromotion",
					// goods2: "/pages/index/goodsPromotion/goodsPromotion1",
					goods1: "/pages/index/goodsScreening/index",
					goods2: "/pages/index/goodsScreening1/index",
					// transport1: "/pages/index/transportList/transport",
					// transport2: "/pages/index/transportList/transport1",
					transport1: "/pages/index/logistics/index",
					transport2: "/pages/index/logistics/index1",
					crossborder1: "/pages/index/freightForwarder/freightForwarder",
					crossborder2: "/pages/index/freightForwarder/freightForwarder",
					professional1: "/pages/index/agencyList/agencyList",
					professional2: "/pages/index/agencyList/agencyList",
					lifead1: "/pages/index/lifeadvertisingList/lifeadvertisingList",
					lifead2: "/pages/index/lifeadvertisingList/lifeadvertisingList",
					news1: "/pages/index/candrNewsList/candrNewsList",
					news2: "/pages/index/candrNewsList/candrNewsList",
					exposure1: "/pages/index/exposureTableList/exposureTableList",
					exposure2: "/pages/index/exposureTableList/exposureTableList",
					library1: "/pages/user/repository/repository",
					library2: "/pages/user/repository/repository",
				},
				isAuthentication: false, //控制认证弹窗
				listLang: [],
				fabu_auth: [], //用户发布权限
				look_auth: [], //金刚区权限
				releaseTotalCount: 0, //设计弹窗使用
				updateIsShow: false,
				logOff: "",
				mobile: "",
				chatMessageModalIsShow: false,
				chatMessage: "",
				lang: uni.getStorageSync("lang"),
				plat: '',
				platform: '',
				user_id: '',
			}
		},
		onLoad() {
			this.getUserAuth2();
			this.getToken()

			var that = this

			// #ifdef APP-PLUS
			login();
			plus.runtime.getProperty(plus.runtime.appid, (wgtinfo) => {
				uni.setStorage({
					key: 'wgtinfoVersionCode',
					data: wgtinfo.version
				})
				this.version = wgtinfo.version
			})

			//检测更新
			let plat = uni.getStorageSync('plat')

			that.plat = plat
			const systemInfo = uni.getSystemInfoSync();
			const platform = systemInfo.platform;
			that.platform = platform
			if (plat == 'app') {
				getPermissions();
				if (that.platform == 'ios') {
					that.requestIosPermission2('record')
				} else {
					that.requestAndroidPermission('record')
					that.xuanfuchuang()
				}
			} else {
				uni.getSystemInfo({
					success: res => {
						if (res.uniPlatform === 'app') {
							that.plat = 'app'
						} else if (res.uniPlatform === 'web') {
							that.plat = 'web'
						} else if (res.uniPlatform === 'mp-weixin') {
							that.plat = 'mp-weixin'
						}
						uni.setStorage({
							key: 'plat',
							data: that.plat
						})

						const systemInfo = uni.getSystemInfoSync();
						const platform = systemInfo.platform;
						that.platform = platform
						if (that.plat == 'app') {
							getPermissions();
							if (platform == 'ios') {
								that.requestIosPermission2('record')
							} else {
								that.requestAndroidPermission('record')
								that.xuanfuchuang()
							}
						}
					}
				})
			}
			// #endif
		},
		onShow() {



			this.getUserInfo()
			this.mobile = uni.getStorageSync("mobile")
			this.lang = uni.getStorageSync("lang")

			this.setTabbarName()


			this.getUserAuth2();
			this.getToken()

			this.userInfoFull = uni.getStorageSync("userInfoFull")

			this.$store.commit("getC2cUnreadMsgNum")

			this.updateIsShow = false;
			setTimeout(() => {
				this.updateIsShow = true;
			}, 100)


			// 判断是否选择语言
			const lang = uni.getStorageSync('lang')
			if (!lang) {
				this.$u.route({
					url: '/pages/tabbar/startPage/language'
				})
				return false
			}

			const startPage = uni.getStorageSync('startPage');
			if (!startPage) {
				this.$u.route({
					url: '/pages/tabbar/startPage/startPage',
					type: 'reLaunch'
				})
				return false
			}

			const step = 1000 * 60 * 60 * 24;
			if (startPage && new Date().getTime() - startPage > step) {
				this.$u.route({
					url: '/pages/tabbar/startPage/startPage',
					type: 'reLaunch'
				})
				return false
			}
			// ------------------------
			// 获取语言
			this.getLang()
			// 获取首页横向滚动区域数据

			// 获取轮播图
			this.getSwiper()

			this.getC2cUnreadMsgNum()

			// 获取广播消息
			this.getMessageList()
			// 弹窗逻辑接口
			this.getActivity()

			//昵称进入缓存
			this.getInfo()

			this.getLogin()

		},
		methods: {
			async getUserInfo() {
				console.log('执行');
				var userinfo = "";
				const {
					deviceBrand,
					deviceModel,
					deviceId,
					osName,
					osVersion
				} = uni.getSystemInfoSync();
				userinfo = deviceBrand + ',' + deviceModel + ',' + deviceId + ',' + osName + ',' + osVersion
				let user = await this.$u.api.user.getUserInfo({
					userinfo: userinfo
				});
				this.userInfoFull = user;
				console.log('this.userInfoFull:', this.userInfoFull);
				uni.setStorageSync("userInfoFull", user)
			},
			// #ifdef APP-PLUS
			//悬浮窗权限检测
			xuanfuchuang() {
				var that = this
				let plat = uni.getStorageSync('plat')
				that.plat = plat
				const systemInfo = uni.getSystemInfoSync();
				const platform = systemInfo.platform;
				that.platform = platform
				uni.setStorageSync('platform', platform)
				if (plat == 'app') {

					if (that.platform != 'ios') {
						let main = plus.android.runtimeMainActivity();
						let pkName = main.getPackageName()
						let Settings = plus.android.importClass('android.provider.Settings')
						let Uri = plus.android.importClass('android.net.Uri')
						let Intent = plus.android.importClass('android.content.Intent')
						let intent = new Intent(
							'android.settings.action.MANAGE_OVERLAY_PERMISSION',
							Uri.parse('package:' + pkName)
						)
						// 检测悬浮窗  
						if (!Settings.canDrawOverlays(main)) {
							uni.setStorageSync('xuanfuchuang_permission', 0);
						} else {
							uni.setStorageSync('xuanfuchuang_permission', 1);
						}
					}
				}
			},
			// #endif


			//安卓麦克风权限
			async requestAndroidPermission(id) {
				var that = this
				var result = await permision.requestAndroidPermission(id)
				if (result == 1) {
					uni.setStorageSync('record_permission', 1);
				} else if (result == 0) {
					uni.setStorageSync('record_permission', 0);
				} else {
					//uni.setStorageSync('record_permission', 1);
				}
			},

			//ios麦克风权限
			async requestIosPermission2(id) {
				var that = this
				var result = await permision.judgeIosPermission(id)
				if (result == false) {
					uni.setStorageSync('record_permission', 0);
				} else {
					uni.setStorageSync('record_permission', 1);
				}
			},

			customer() {
				uni.navigateTo({
					url: "/pages/message/message/service"
				})
			},
			setTabbarName() {
				if (uni.getStorageSync("lang") != 'ru') {
					uni.setTabBarItem({
						index: 0, // tabIndex，tabbar的哪一项，从0开始
						text: '首页', // 新的名称
					});
					uni.setTabBarItem({
						index: 1, // tabIndex，tabbar的哪一项，从0开始
						text: '工作台', // 新的名称
					});
					uni.setTabBarItem({
						index: 2, // tabIndex，tabbar的哪一项，从0开始
						text: '发布', // 新的名称
					});
					uni.setTabBarItem({
						index: 3, // tabIndex，tabbar的哪一项，从0开始
						text: '消息', // 新的名称
					});
					uni.setTabBarItem({
						index: 4, // tabIndex，tabbar的哪一项，从0开始
						text: '我的', // 新的名称
					});
				} else {
					uni.setTabBarItem({
						index: 0, // tabIndex，tabbar的哪一项，从0开始
						text: 'Главная', // 新的名称
					});
					uni.setTabBarItem({
						index: 1, // tabIndex，tabbar的哪一项，从0开始
						text: 'Кабинет', // 新的名称
					});
					uni.setTabBarItem({
						index: 2, // tabIndex，tabbar的哪一项，从0开始
						text: 'Опубликовать', // 新的名称
					});
					uni.setTabBarItem({
						index: 3, // tabIndex，tabbar的哪一项，从0开始
						text: 'Сообщения', // 新的名称
					});
					uni.setTabBarItem({
						index: 4, // tabIndex，tabbar的哪一项，从0开始
						text: 'Мой', // 新的名称
					});
				}
			},
			//退出登录
			logOut() {
				const agreeApp = uni.getStorageSync("agreeApp")

				uni.clearStorage();
				uni.clearStorageSync();

				if (agreeApp) uni.setStorageSync("agreeApp", agreeApp)

				// #ifndef MP-WEIXIN
				let chat = TencentCloudChat.create({
					SDKAppID: 1400818966
				});
				let promise1 = chat.logout();
				promise1.then(function(imResponse) {
					console.log(imResponse.data); // 登出成功
				}).catch(function(imError) {
					console.warn('logout error:', imError);
				});
				// #endif

				this.$u.toast(this.$t('操作成功'))
				setTimeout(() => {
					this.$u.route({
						// url: '/pages/tabbar/startPage/language'
						url: '/pages/user/login/login',
					})
				}, 2000)
				return false
			},
			//获取登录状态
			getLogin() {
				if (this.$isLogin()) {
					this.$u.api.user.getUserAuth().then(re => {
						//uni.setStorageSync('user_id', re.id);
						this.user_id = re.id
						this.$u.api.user.getUserAuthIcon({
							user_id: re.id
						}).then(res => {
							// this.iconList = res
							this.jurisdictionList = [...res[2], ...res[1]]
						})
					})
				} else {
					this.$u.api.basic.getHomeIcon().then(res => {
						this.jurisdictionList = [...res[2], ...res[1]]
						// this.iconList = res
					})
				}
			},
			goTest() {
				// uni.navigateTo({
				// 	url: "/pages/zWebView/zWebView"
				// })
				// return
				uni.navigateTo({
					url: "/pages/webview/test/test"
				})
			},
			// 获取 权限
			getUserAuth2() {
				this.$u.api.user.appCheck().then(res => {
					console.log(res)
					this.logOff = res.logOff;
					uni.setStorageSync('off', res.logOff);
					uni.setStorageSync('permissionsShow', res.permissionsShow);
					this.$u.api.user.getUserAudit().then(r => {
						if (r.user_id > 0) {
							console.log(r)
							this.user_id = r.user_id
						}
						uni.setStorageSync("fabu_auth", r.fabu_auth)
						uni.setStorageSync("look_auth", r.look_auth)

						if (res.authShow && r.status == '0' && uni.getStorageSync("xzdToken")) {
							this.isAuthentication = true;
						} else {
							this.isAuthentication = false
						}
					})
				})
			},
			// 获取token
			getToken() {
				if (this.$isLogin()) {
					this.getUserAudit()
				}

			},
			// 获取用户权限
			getUserAudit() {
				this.$u.api.user.getUserAudit().then(res => {
					// 认证状态,res.status
					this.identity_id = res.identity_type
					// 判断用户是否认证，
					if (res.status == 2) {
						this.getActivity()
					}
					if (res.fabu_auth !== '') {
						this.fabu_auth = res.fabu_auth.split(",");
					}
					if (res.look_auth !== '') {
						this.look_auth = res.look_auth.split(",");
					}
				})
			},

			// 获取用户身份
			getInfo() {
				var that = this
				var userinfo = "";
				const {
					deviceBrand,
					deviceModel,
					deviceId,
					osName,
					osVersion
				} = uni.getSystemInfoSync();
				userinfo = deviceBrand + ',' + deviceModel + ',' + deviceId + ',' + osName + ',' + osVersion
				that.$u.api.user.getUserInfo({
					userinfo: userinfo
				}).then(res => {
					uni.setStorageSync('identity_type', res.identity_type);
					if (that.lang == 'zh') {
						uni.setStorageSync('nickname', res.username);
					} else {
						uni.setStorageSync('nickname', res.username_ru);
					}
				});
				// #ifdef APP-PLUS
				plus.push.getClientInfoAsync((info) => { //个推不引了  此代码就没用了
					let cid = info["clientid"];
					userinfo = deviceBrand + ',' + deviceModel + ',' + deviceId + ',' + osName + ',' + osVersion +
						',' + cid
					that.$u.api.user.getUserInfo({
						userinfo: userinfo
					});
				});
				// #endif
			},
			// 点击了活动的弹窗关闭按钮或者遮罩层
			close() {
				this.show = false
				uni.setStorageSync('activityNum', 5);
			},
			// 中国活动
			handeleActivities() {
				uni.setStorageSync('activityNum', 5);
				this.show = false
				uni.navigateTo({
					url: '/pages/release/merchantRelease/merchantRelease'
				})
			},
			// 中国活动弹窗逻辑接口
			getActivity() {
				const value1 = this.$isLogin()
				const value2 = uni.getStorageSync('activityNum');
				const validTypes = [2, 3, 4, 5, 6, 7];
				if (value1.length > 0 && value2 == 0 && validTypes.includes(this.identity_id)) {
					// 调接口判断用户是否发布过内容，未发布为0，如果已发布过，则不弹窗
					this.$u.api.basic.activity_tan({}).then(result => {

						if (result === 0 && this.lang == 'zh') {
							this.show = true
						} else {
							this.show = false
						}
					})
				}
			},
			// 广播消息
			getMessageList() {
				this.$u.api.message.getMessageList().then(res => {
					this.list = res
				})
			},
			handelePoa(index, item) {
				if (index === 1) {
					uni.navigateTo({
						url: '/pages/release/goods/form?type=2'
					})
				} else {
					createC2CConversation(item.user.mobile, this)
				}
			},

			// 音频通话
			ceshiVoiceCall(item) {
				createVoiceCall(item.user.mobile, this)
			},

			// 点击商品推荐商品跳转到详情页
			handeleGoos(item) {
				uni.navigateTo({
					url: '/pages/index/detail/detail2?id=' + item.id + '&type=' + '1' + '&releaseType=' + 'goods'
				})
			},
			// 点击猜你喜欢商品跳转到详情页
			handeleLike(item) {
				uni.navigateTo({
					url: '/pages/index/detail/detail2?id=' + item.id + '&type=' + '1' + '&releaseType=' + 'goods'
				})
			},
			// /pages/index/detail/detail?id=2988&type=1&releaseType=goods
			scroll() {},
			// 输入框点击键盘搜索
			handeleSearch() {
				this.getSwiper()
			},
			// tabbar 在原有tabbar/index  页面赋值过来的
			getC2cUnreadMsgNum() {
				const that = this
				const mobile = uni.getStorageSync('mobile')
				that.isShow = 1
				that.$u.api.message.getC2cUnreadMsgNum({
					mobile: mobile,
				}).then(res => {
					that.$u.api.basic.getNoticeNum().then(r => {
						that.listLang = [{
								iconPath: "/static/images/tabbar/newStyle/t1.png",
								selectedIconPath: "/static/images/tabbar/t1s.png",
								text: that.$t('首页'),
								// count: 2,
								// isDot: true,
								customIcon: false,
								pagePath: '/pages/tabbar/index'
							},
							{
								iconPath: "/static/images/tabbar/newStyle/t2.png",
								selectedIconPath: "/static/images/tabbar/t2s.png",
								text: that.$t('订单'),
								customIcon: false,
								// isDot: true,
								pagePath: '/pages/tabbar/order/index'
							},
							{
								iconPath: "/static/images/tabbar/newStyle/t3.png",
								selectedIconPath: "/static/images/tabbar/t3s.png",
								text: that.$t('发布'),
								midButton: true,
								customIcon: false,
								pagePath: '/pages/tabbar/release/index'
							},
							{
								iconPath: "/static/images/tabbar/newStyle/t4.png",
								selectedIconPath: "/static/images/tabbar/t4s.png",
								text: that.$t('消息'),
								count: Number(res.AllC2CUnreadMsgNum) + Number(r.other) + Number(r
									.system),
								customIcon: false,
								pagePath: '/TUIKit/components/TUIConversation/list'
							},
							{
								iconPath: "/static/images/tabbar/newStyle/t5.png",
								selectedIconPath: "/static/images/tabbar/t5s.png",
								text: that.$t('我的'),
								// count: 23,
								// isDot: false,
								customIcon: false,
								pagePath: '/pages/tabbar/user/index'
							},
						]
						that.isShow = 0

					})
				})
			},


			// 跳转至认证页面
			handeleGoAuthentication() {
				uni.navigateTo({
					url: '/pages/user/register/authentication'
				})
			},
			// AI助手
			goAi() {
				uni.navigateTo({
					url: "/pages/webview/test/test"
				})
			},
			// 获取语言
			getLang() {
				// 获取缓存lang当前语言值
				uni.getStorage({
					key: 'lang',
					success: res => {
						if (res.data == 'zh') { //zh为中国，赋值0
							this.lang = 'zh'
						} else { //其他为俄罗斯，赋值1
							this.lang = 'ru'
						}
					}
				});
			},
			// 获取轮播图  猜你喜欢   商品推荐
			getSwiper() {
				let data = {
					searchKey: this.inputValue,
					type: this.current + 1,
					city: this.show_city,
					page: this.page
				}
				this.$u.api.collection.getHomeData(data).then(res => {
					this.swiperList = res.banners.map(item => ({
						image: this.IMGURL + item,
						title: item
					}))
					this.likeList = res.like_list //猜你喜欢
					this.goodsList = res.list //商品推荐
				})
			},

			// 页面跳转
			handeleRouter(item) {
				uni.navigateTo({
					url: this.iconUrl[item.auth] + '?type=' + item.type
				})
			},

			doUpData(Url) {
				uni.showLoading({
					title: '更新中……'
				})
				const downloadTask = uni.downloadFile({ //执行下载
					url: Url, //下载地址
					timeout: 1000 * 30, //30秒超时时间
					success: downloadResult => { //下载成功
						this.showdownLine = false
						uni.hideLoading();
						if (downloadResult.statusCode == 200) {
							plus.runtime.install( //安装软件
								downloadResult.tempFilePath, {
									force: true
								},
								function(res) {
									plus.runtime.restart();
								}
							);
						}
					},
					fail: err => {
						uni.hideLoading();
						this.showdownLine = false
						this.$u.toast(err.errMsg)
					},
					complete: com => {}
				});

				// 下载进度
				downloadTask.onProgressUpdate(res => {
					// this.$u.toast(res.progress)
					this.downloadNum = res.progress
					// console.log('下载进度' + res.progress);
					// console.log('已经下载的数据长度' + res.totalBytesWritten);
					// console.log('预期需要下载的数据总长度' + res.totalBytesExpectedToWrite);

					// 满足测试条件，取消下载任务。
					// if (res.progress > 50) {
					//  downloadTask.abort();
					// }
				});
			},

			checkUpdates(type) {
				//调用接口检查是否可以更新
				// #ifdef APP-PLUS
				var that = this

				var check_update_title = this.$t('更新提示')
				var check_update_desc = this.$t('您的版本过低 请到苹果商店升级到最新版本')
				var check_update_desc2 = this.$t('您的版本过低 请升级到最新版本')

				this.$u.api.basic.getVersion({}).then(res => {
					console.log('getVersion', type, res)
					console.log('后台版本', res.banben);
					console.log('前台版本', that.version);
					console.log('强制', res.qiangzhi);

					var url = res.url
					var qiangzhi = res.qiangzhi
					if (qiangzhi != 3) {
						if (this.version >= res.banben) {
							console.log('不需要更新')
						} else {
							if (type == 'ios') {
								if (qiangzhi == 1) {
									uni.showModal({ //提醒用户更新
										title: check_update_title,
										showCancel: false, // 隐藏取消按钮
										confirmText: that.$t('是'),
										content: check_update_desc,
										success: (res) => {
											const appStoreUrl = res.ios_url;
											// 使用uniapp的API在Webview中打开链接
											uni.navigateTo({
												url: "/pages/webview/webview?url=" +
													appStoreUrl
											});
											return
										}
									})
									return
								} else {
									uni.showModal({ //提醒用户更新
										title: check_update_title,
										content: check_update_desc,
										confirmText: that.$t('是'),
										success: (res) => {}
									})
									return
								}

							} else {
								if (qiangzhi == 1) {
									uni.showModal({ //提醒用户更新
										title: check_update_title,
										showCancel: false, // 隐藏取消按钮
										confirmText: that.$t('是'),
										content: check_update_desc2,
										success: (res) => {
											this.doUpData(url)
											this.showdownLine = true
										}
									})
									return
								} else {
									uni.showModal({ //提醒用户更新
										title: check_update_title,
										content: check_update_desc2,
										confirmText: that.$t('是'),
										success: (res) => {
											console.log('下载地址', url);
											if (res.confirm) {
												this.doUpData(url)
												this.showdownLine = true
												// plus.runtime.openURL(androidUrl)	
											}
										}
									})
								}
							}
						}
					}

				});
				// #endif
			},
		},
		beforeDestroy() {
			this.show = false
		}



	}
</script>

<style scoped>
	.flex {
		display: flex;
		align-items: center;
	}

	.logo {
		position: absolute;
		margin-top: 55rpx;
		z-index: 9;
		width: 100%;
		display: flex;
		align-items: flex-end;
		justify-content: flex-start;
		padding: 0 30rpx;
		box-sizing: border-box;
	}

	.warp {
		width: 100%;
		height: 1200rpx;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.warpImage {
		width: 600rpx;
		height: 450rpx;
		margin-right: 50rpx;
		/* 	position: fixed;
		top: 300rpx;
		left: 100rpx; */
	}

	.china_but {
		width: 250rpx;
		height: 80rpx;
		border-radius: 40rpx;
		background-color: #FFB654;
		display: flex;
		align-items: center;
		justify-content: center;
		color: #FFFFFF;
		margin-top: -30rpx;
	}

	.china_Activities {
		width: 700rpx;
		height: 600rpx;
		display: flex;
		flex-direction: column;
		align-items: center;
	}

	.btn-group {
		position: absolute;
		bottom: -15rpx;
		left: 0;
		z-index: 9;
		width: 100%;
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 0 20rpx;
	}

	.relativeAb_block {
		width: 130rpx;
		height: 40rpx;
		line-height: 40rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		font-size: 22rpx;
		background-color: #4063FF;
		border-radius: 200rpx;
		color: #fff;
	}

	.relativeAb_block2 {
		background-color: #3D3F45;
	}

	.relativeAb {
		width: 100%;
		display: flex;
		justify-content: space-between;
		align-items: center;
	}

	.over-line_salary {
		width: 95%;
		display: flex;
		margin-top: 8rpx;
	}

	.over-line {
		margin-top: 20rpx;
		width: 100%;
		height: 30rpx;
		line-height: 30rpx;
		font-size: 22rpx;
		font-weight: bold;
		word-break: break-all;
		overflow: hidden;
		margin-bottom: 16rpx;
	}

	.classLink_block {
		width: 100%;
		height: 210rpx;
		padding: 0 20rpx;
	}

	.pos_block {
		width: 168rpx;
		height: 48rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		font-size: 17rpx;
	}

	.poa {
		position: absolute;
		width: 336rpx;
		height: 48rpx;
		left: 0;
		top: 0;
		display: flex;
		align-items: center;
		justify-content: space-between;
	}

	.scroll-view_H_wc {
		padding: 0 15rpx;
		display: flex;
		flex-wrap: wrap;
		justify-content: space-between;
		align-items: center;
	}

	.scroll-content {
		display: flex;
		flex-direction: row;
		min-height: 120rpx;
	}

	.index_jurs {
		width: calc(100% - 60rpx);
		min-height: 120rpx;
		margin-top: 27rpx;
	}

	.container_zh {
		/* background-color: blue; */
		text-align: center;
		font-size: 24rpx;
		width: 100rpx;
		overflow-wrap: break-word;
		/* or word-wrap: break-word; */
		white-space: normal;
		/* default value, but included for clarity */
	}

	.container_ru {
		line-height: 1;
		/* background-color: blue; */
		text-align: center;
		font-size: 15rpx;
		width: 100rpx;
		overflow-wrap: break-word;
		/* or word-wrap: break-word; */
		white-space: normal;
		/* default value, but included for clarity */
	}

	.scroll-view {
		width: 100%;
		min-height: 115rpx;
		white-space: nowrap;
		margin-top: 12rpx;
	}

	.item {
		width: 80px;
		min-height: 65px;
		display: flex;
		flex-direction: column;
		align-items: center;
		margin-right: 52rpx;
		margin-bottom: 28rpx;
	}

	.huanhang {
		width: 100rpx;
		font-size: 18rpx;
		text-align: center;
		color: rgb(0, 0, 0);
		word-break: break-word;
		font-size: 24rpx;
	}

	.index_reminder_Aut {
		width: 80%;
		height: 500rpx;
		font-size: 40rpx;
		overflow-y: scroll;
	}

	.index_reminder {
		width: 100%;
		height: 150rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		font-size: 38rpx;
		font-weight: 600;
	}

	.index_isAuthentication {
		width: 600rpx;
		height: 700rpx;
		display: flex;
		flex-direction: column;
		align-items: center;
	}

	.goAi {
		position: fixed;
		right: 2%;
		bottom: 20%;
		z-index: 999;
		background-color: #fff;
		width: 150rpx;
		height: 150rpx;
		border-radius: 50%;
		display: flex;
		align-items: center;
		justify-content: center;
		flex-direction: column;
		box-shadow: 0 0 10rpx rgba(0, 0, 0, 0.1);
	}

	.scroll-container_cs {
		width: 100%;
		/* 设置容器宽度 */
		overflow-x: auto;
		/* 启用横向滚动 */
		white-space: nowrap;
		/* 确保子项不换行 */
	}

	.scroll-content_cs {
		display: inline-block;
		/* 使内容横向排列 */
	}

	.item_cs {
		margin-right: 54rpx;
		display: inline-block;
		/* 使每个项目横向排列 */
		width: 80rpx;
		/* 设置项目宽度 */
		height: 120rpx;
		/* 设置项目高度 */
		background-color: lightblue;
		/* 只是为了视觉效果 */
	}

	.index_wrap {
		height: 100rpx;
		width: 100rpx;
		word-break: break-all;
		/* 强制任何字符换行，包括在单词内部 */
		font-size: 24rpx;
		overflow-wrap: break-word;
		/* 尝试增加这个属性 */
	}

	.iconRout {
		width: 100rpx;
		text-align: center;
		word-break: break-all;

	}

	.goodsBrief {
		width: 336rpx;
		height: 33rpx;
		margin-top: 6rpx;
		min-height: 31rpx;
		font-size: 24rpx;
		color: #3D3D3D;
		word-break: break-all;
		overflow: hidden;
		display: -webkit-box;
		-webkit-line-clamp: 1;
		-webkit-box-orient: vertical;
		padding: 0 16rpx;
	}

	.goodsTitle {
		width: 336rpx;
		font-size: 28rpx;
		color: #3D3D3D;
		text-overflow: ellipsis;
		overflow: hidden;
		word-break: break-all;
		white-space: nowrap;
		padding: 15rpx 16rpx 0;
	}

	.images_header {
		width: 100%;
		height: 820rpx;
		position: absolute;
		top: -150rpx;
		z-index: 1;
	}

	.scroll-view_H {
		white-space: nowrap;
		width: 100%;
		height: 231rpx;
	}

	.scroll-view-item_H {
		display: inline-block;
		width: 100%;
		height: 300rpx;
		line-height: 300rpx;
		text-align: center;
		font-size: 36rpx;
	}

	.images_block_s {
		width: 332rpx;
		height: 138rpx;
		border-radius: 16rpx;
		background-color: red;
		margin-bottom: 20rpx;
	}

	.images_block_d {
		width: 332rpx;
		height: 138rpx;
		border-radius: 16rpx;
		background-color: blue;
		margin-left: 22rpx;
		margin-bottom: 20rpx;
	}

	.images_list {
		width: 100%;
		min-height: 80rpx;
		display: flex;
		flex-wrap: wrap;
	}

	.goods_block_d {
		width: 336rpx;
		min-height: 460rpx;
		border-radius: 16rpx;
		margin-bottom: 80rpx;
		display: flex;
		flex-direction: column;
		background: #F6F6F6;
	}

	.goods_block_s {
		width: 336rpx;
		min-height: 460rpx;
		border-radius: 16rpx;
		margin-left: 18rpx;
		margin-bottom: 80rpx;
		display: flex;
		flex-direction: column;
		background: #F6F6F6;
	}

	.goods_container {
		width: 100%;
		min-height: 500rpx;
		display: flex;
		flex-wrap: wrap;

	}

	.Vertical_line {
		width: 8rpx;
		height: 36rpx;
		background: linear-gradient(134deg, #D9F0A3 0%, rgba(217, 240, 163, 0.411) 55%, rgba(201, 239, 49, 0) 100%);
		border-radius: 22rpx 22rpx 22rpx 22rpx;
		margin-right: 8rpx;
	}



	.index_recommend {
		border-top-left-radius: 28rpx;
		border-top-right-radius: 28rpx;
		width: 100%;
		min-height: 500rpx;
		display: flex;
		flex-direction: column;
		margin-top: 20rpx;
		background-color: #FFFFFF;
		padding: 0rpx 30rpx 32rpx 30rpx;
	}

	.goodsImage {
		width: 100%;
		position: relative;
		margin-right: 16rpx;
		border-radius: 16rpx;
		background-color: #FFFFFF;
		margin-bottom: 16rpx;
	}

	.backTJ {
		margin-top: 20rpx;
		margin-left: -53rpx;
		width: 100rpx;
		height: 22rpx;
		border-radius: 22rpx;
		background: linear-gradient(134deg, #D9F0A3 0%, rgba(217, 240, 163, 0.411) 55%, rgba(201, 239, 49, 0) 100%);
		z-index: 99;
	}

	.recommendTJ {
		height: 88rpx;
		margin-left: 16rpx;
		width: 90%;
		display: flex;
		align-items: center;
		font-size: 32rpx;
		font-weight: 700;
	}

	.goodsTJ {
		height: 88rpx;
		margin-left: 16rpx;
		width: 100%;
		display: flex;
		align-items: center;
		font-size: 32rpx;
		font-weight: 700;
		position: relative;
	}

	.commodityTJ {
		width: 100%;
	}

	.scroll-content_ {
		display: flex;
		flex-direction: row;
		height: 201rpx;
	}

	.scroll-links_block {
		width: 100%;
		height: 205rpx;
		white-space: nowrap;
		margin-top: 1rpx;
	}



	.goodsBlock {
		width: 100%;
		height: 240rpx;
	}



	.link_scroll-content {
		display: flex;
		flex-direction: row;
		height: 201rpx;
	}







	.index_jur {
		width: 80rpx;
		height: 120rpx;
		background-color: blue;
	}

	.index_min_Swiper {
		width: calc(100% - 60rpx);
		height: 146rpx;
		margin: 20rpx 0 20rpx 0;
	}

	.index_Swiper {
		width: calc(100% - 60rpx);
		height: 240rpx;
		margin-top: 20rpx;
	}

	.index_Search {
		width: calc(100% - 60rpx);
		height: 64rpx;
		border-radius: 12rpx;
		border: 2rpx solid #000000;
		margin-top: 120rpx;
		display: flex;
		align-items: center;
		padding: 20rpx;
	}

	.index_header {
		width: 100%;
		height: 364rpx;
		display: flex;
		flex-direction: column;
		align-items: center;
		z-index: 100;
	}

	.index_Content {
		width: 100%;
		display: flex;
		flex-direction: column;
		align-items: center;
	}

	.Outer_container {
		display: flex;
		flex-direction: column;
		align-items: center;
		width: 100%;
		min-height: 758rpx;
		border-radius: 0rpx 0rpx 28rpx 28rpx;
	}

	.goindex {
		position: fixed;
		right: 30rpx;
		bottom: 300rpx;
		width: 120rpx;
		height: 120rpx;
		background-color: #fff;
		border-radius: 20rpx;
		z-index: 999;
		display: flex;
		align-items: center;
		justify-content: center;
		font-size: 24rpx;
		display: flex;
		flex-direction: column;
		/* color:#1637ed; */
		color: #3d3d3d;
		font-weight: bold;
	}
</style>
<style lang="scss">
	page {
		background-color: #F6F6F6;
	}

	.chatMessageBtn {
		width: 100%;
		padding: 0 30rpx;
		box-sizing: border-box;
		position: relative;
		z-index: 9;
		margin-top: 80rpx;

		.title {
			position: absolute;
			top: 76rpx;
			left: 76rpx;
			z-index: 9;
		}

		.title2 {
			position: absolute;
			top: 76rpx;
			left: 65rpx;
			z-index: 9;
		}
	}

	.header-text {
		position: absolute;
		z-index: 10;
		top: 200rpx;
		width: 100%;
		padding-left: 50rpx;
		box-sizing: border-box;
		display: flex;
		align-items: center;
		justify-content: flex-start;
		height: 260rpx;
		left: 0;
		overflow: hidden;
	}
</style>